<html>
<head><meta charset="utf-8"><title>Rustdoc unconditionally links to nightly libstd docs · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html">Rustdoc unconditionally links to nightly libstd docs</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="230811595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/230811595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#230811595">(Mar 18 2021 at 04:12)</a>:</h4>
<p><span class="user-mention" data-user-id="322291">@codic</span> noticed in #rustdoc on discord that rustdoc unconditionally links to the nightly libstd docs, even from stable or beta toolchains. That happens because the standard library uses <code>doc(html_root_url = "nightly")</code> even on beta and stable channels: <a href="https://github.com/rust-lang/rust/blob/stable/library/std/src/lib.rs#L192">https://github.com/rust-lang/rust/blob/stable/library/std/src/lib.rs#L192</a>. How hard would it be change that only on those channels?</p>



<a name="230811739"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/230811739" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#230811739">(Mar 18 2021 at 04:15)</a>:</h4>
<p>I guess maybe this is a question for <a class="stream" data-stream-id="241545" href="/#narrow/stream/241545-t-release">#t-release</a>? cc <span class="user-mention" data-user-id="116122">@simulacrum</span></p>



<a name="230811831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/230811831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#230811831">(Mar 18 2021 at 04:16)</a>:</h4>
<p>the diff itself is trivial:</p>
<div class="codehilite" data-code-language="Diff"><pre><span></span><code><span class="gh">diff --git a/library/std/src/lib.rs b/library/std/src/lib.rs</span>
<span class="gh">index 8149858e103..0e186ff22c8 100644</span>
<span class="gd">--- a/library/std/src/lib.rs</span>
<span class="gi">+++ b/library/std/src/lib.rs</span>
<span class="gu">@@ -190,7 +190,7 @@</span>
 #![cfg_attr(not(feature = "restricted-std"), stable(feature = "rust1", since = "1.0.0"))]
 #![cfg_attr(feature = "restricted-std", unstable(feature = "restricted_std", issue = "none"))]
 #![doc(
<span class="gd">-    html_root_url = "https://doc.rust-lang.org/nightly/",</span>
<span class="gi">+    html_root_url = "https://doc.rust-lang.org/stable/",</span>
     html_playground_url = "https://play.rust-lang.org/",
     issue_tracker_base_url = "https://github.com/rust-lang/rust/issues/",
     test(no_crate_inject, attr(deny(warnings))),
</code></pre></div>



<a name="230849710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/230849710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#230849710">(Mar 18 2021 at 11:50)</a>:</h4>
<p>I think the intent was that we want the most up to date docs, but I'm not sure if it actually makes sense. I'd rather not add changing this line to the release process if we can avoid it, though. Is the problem that nightly docs are too up to date? I guess I'm always reading them pretty much</p>



<a name="230871885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/230871885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#230871885">(Mar 18 2021 at 14:25)</a>:</h4>
<p>the problem is the nightly docs don't match what you're actually using in your code - it could e.g. show a function as deprecated or add a function/trait with the same name as an extension trait you're using</p>



<a name="230871916"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/230871916" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#230871916">(Mar 18 2021 at 14:25)</a>:</h4>
<p>which is not a <em>super</em> giant deal, but seems bad to have when we can avoid it</p>



<a name="230872371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/230872371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#230872371">(Mar 18 2021 at 14:28)</a>:</h4>
<blockquote>
<p>I'd rather not add changing this line to the release process if we can avoid it, though.</p>
</blockquote>
<p>Is there a way to change it on the git branch, so that you only have to change it once, not every release process?</p>



<a name="230944340"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/230944340" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> codic <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#230944340">(Mar 18 2021 at 22:01)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs/near/230811595">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="322291">codic</span> noticed in #rustdoc on discord that rustdoc unconditionally links to the nightly libstd docs, even from stable or beta toolchains. That happens because the standard library uses <code>doc(html_root_url = "nightly")</code> even on beta and stable channels: <a href="https://github.com/rust-lang/rust/blob/stable/library/std/src/lib.rs#L192">https://github.com/rust-lang/rust/blob/stable/library/std/src/lib.rs#L192</a>. How hard would it be change that only on those channels?</p>
</blockquote>
<p>Indeed; the issue with linking to nightly std is that stuff may have broken and be different from the latest stable; eg a function may be described as taking a parameter in nightly that does not exist in stable. Perhaps this should read the Rustc / cargo version and determine what to link to accordingly?</p>



<a name="230945028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/230945028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#230945028">(Mar 18 2021 at 22:06)</a>:</h4>
<p>well theoretically libstd should never have breaking changes</p>



<a name="230945065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/230945065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#230945065">(Mar 18 2021 at 22:07)</a>:</h4>
<blockquote>
<p>Perhaps this should read the Rustc / cargo version and determine what to link to accordingly?</p>
</blockquote>
<p>I would <em>really</em> prefer not to special case libstd in rustdoc more than it already is, primitives are already an unmaintainable mess</p>



<a name="230949947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/230949947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#230949947">(Mar 18 2021 at 22:58)</a>:</h4>
<p>actually an easier way might be to read <code>CFG_RELEASE_CHANNEL</code> and use <code>html_root_url = concat!("doc.rust-lang.org/", env!("CFG_RELEASE_CHANNEL")</code>? I don't know if bootstrap sets that for libstd currently but it seems like it shouldn't be too hard</p>



<a name="230950924"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/230950924" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#230950924">(Mar 18 2021 at 23:08)</a>:</h4>
<p>I guess that means other build systems like -Z build-std have to start setting it too, maybe I could extend env! to take a default value or something</p>



<a name="231222940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/231222940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#231222940">(Mar 21 2021 at 15:31)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs/near/230949947">said</a>:</p>
<blockquote>
<p>actually an easier way might be to read <code>CFG_RELEASE_CHANNEL</code> and use <code>html_root_url = concat!("doc.rust-lang.org/", env!("CFG_RELEASE_CHANNEL")</code>? I don't know if bootstrap sets that for libstd currently but it seems like it shouldn't be too hard</p>
</blockquote>
<p>nope this doesn't work</p>
<div class="codehilite"><pre><span></span><code>error: expected unsuffixed literal or identifier, found `concat`
   --&gt; library/std/src/lib.rs:193:21
    |
193 |     html_root_url = concat!(&quot;https://doc.rust-lang.org/&quot;, env!(&quot;CFG_RELEASE_CHANNEL&quot;)),
    |                     ^^^^^^
</code></pre></div>



<a name="231222986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/231222986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#231222986">(Mar 21 2021 at 15:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs/near/230872371">said</a>:</p>
<blockquote>
<blockquote>
<p>I'd rather not add changing this line to the release process if we can avoid it, though.</p>
</blockquote>
<p>Is there a way to change it on the git branch, so that you only have to change it once, not every release process?</p>
</blockquote>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> ^ do you know if this is possible?</p>



<a name="231223124"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/231223124" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#231223124">(Mar 21 2021 at 15:34)</a>:</h4>
<p>We can probably make it happen via -Zextra-attr or something like that, IIRC that's already existing in the compiler. But I'm not sure we <em>should</em>, so I think investing time in this may not be the right call. I would want an RFC-like document laying out the rationale, and it's probably worth speaking to some of the people historically involved with this -- e.g., Steve -- and perhaps the libs team. I think there are concrete benefits to linking to nightly (and concrete downsides), and evaluating which should be done feels like a decision best made with a document in hand.</p>



<a name="231223130"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/231223130" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#231223130">(Mar 21 2021 at 15:35)</a>:</h4>
<p>wrt to changing on the git branch, no</p>



<a name="231223257"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/231223257" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#231223257">(Mar 21 2021 at 15:36)</a>:</h4>
<p><span class="user-mention" data-user-id="322291">@codic</span> I am probably not going to invest much time into the RFC - happy to mentor you on writing it up if you're interested though :)</p>



<a name="231223272"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/231223272" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#231223272">(Mar 21 2021 at 15:37)</a>:</h4>
<blockquote>
<p>We can probably make it happen via -Zextra-attr or something like that, IIRC that's already existing in the compiler. B</p>
</blockquote>
<p>looks like this is <code>-Z crate-attr</code></p>
<div class="codehilite"><pre><span></span><code>&gt; rustc -Zhelp | grep attr
    -Z                     crate-attr=val -- inject the given attribute in the crate
</code></pre></div>



<a name="231255639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/231255639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Noah Lev <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#231255639">(Mar 22 2021 at 02:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs/near/231222940">said</a>:</p>
<blockquote>
<p><span class="user-mention silent" data-user-id="232545">Joshua Nelson</span> <a href="#narrow/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs/near/230949947">said</a>:</p>
<blockquote>
<p>actually an easier way might be to read <code>CFG_RELEASE_CHANNEL</code> and use <code>html_root_url = concat!("doc.rust-lang.org/", env!("CFG_RELEASE_CHANNEL")</code>? I don't know if bootstrap sets that for libstd currently but it seems like it shouldn't be too hard</p>
</blockquote>
<p>nope this doesn't work</p>
<p><div class="codehilite"><pre><span></span><code>error: expected unsuffixed literal or identifier, found `concat`
   --&gt; library/std/src/lib.rs:193:21
    |
193 |     html_root_url = concat!(&quot;https://doc.rust-lang.org/&quot;, env!(&quot;CFG_RELEASE_CHANNEL&quot;)),
    |                     ^^^^^^
</code></pre></div><br>
</p>
</blockquote>
<p>Hmm, why doesn't <code>extended_key_value_attributes</code> fix that?</p>



<a name="231255660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Rustdoc%20unconditionally%20links%20to%20nightly%20libstd%20docs/near/231255660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Rustdoc.20unconditionally.20links.20to.20nightly.20libstd.20docs.html#231255660">(Mar 22 2021 at 02:04)</a>:</h4>
<p>it only applies one level deep <a href="#narrow/stream/182449-t-compiler.2Fhelp/topic/Allow.20expression.20for.20doc(alias).20too">https://rust-lang.zulipchat.com/#narrow/stream/182449-t-compiler.2Fhelp/topic/Allow.20expression.20for.20doc(alias).20too</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>